package evolutionaryLoop.selectionMechanisme;

import java.util.ArrayList;
import java.util.List;

import evolutionaryLoop.Population;

public class FitnessSelection extends GlobalSelectionMechanisme{
	
	public FitnessSelection(){
	}

	@Override
	public void setPopulation(Population population) {
		phenotypeList = population.getPopulationList(); 
		
		double sumOfFitness = getSumOfFitness(); 
		List<Double> probabilityList = new ArrayList<Double>(phenotypeList.size());
		for (int i = 0; i < phenotypeList.size(); i++){
			probabilityList.add(phenotypeList.get(i).getFitness()/sumOfFitness);
		}
		scaledFitnessList = probabilityList; 
	}

	public String toString(){
		return "Fitness selection"; 
	}
}
